package com.mini.admin.api.dto;

import com.mini.common.core.contraint.Phone;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author Zhou Feng
 */
@Data
@ApiModel
public class ListMenuParamDTO {
    @NotNull(message = "父id必须提交")
    @ApiModelProperty(value = "父id", example = "0")
    private Long parentId;
    @NotBlank(message = "test不能为空")
    @ApiModelProperty(value = "test字段",example = "tte")
    private String test;
    @Phone(regexp = "^\\d{11}$")
    @ApiModelProperty(value = "手机号",example = "12345678901")
    private String phone;

    //嵌套校验，可以校验 List
    @Valid
    @NotEmpty(message = "学生列表不能为空")
    private List<Student> students;
}

@Data
class Student{
    @Range(min = 0L, max = 150L, message = "年龄范围超了")
    private int age;

    @Length(min = 0, max = 5, message = "名称范围超了")
    private String name;

}